
<?php $baseUrl=Zend_Controller_Front::getInstance()->getBaseUrl(); ?>

        <table width="100%">
            <?php
            for($i=($this->currentPage - 1)*$this->pagesize;$i< $this->currentPage*$this->pagesize;$i++)
            {
                if($i>=count($this->newbook))
                        break;
                if($i==0)
                {
                    echo "<tr>";
                }
                else if($i%3==0)
                {
                   echo "</tr>" ;
                   echo "<tr>";
                }
            ?>
                <td>
                    <a href="<?php echo $baseUrl . '/default/book/detail/id/'.$this->newbook[$i]["_id"]; ?>">
                        <img src="<?php echo $this->newbook[$i]["image"];  ?>" alt="" class="abook"/>
                    </a>
                    <br/>
                    <a href="<?php echo $baseUrl . '/default/book/detail/id/'.$this->newbook[$i]["_id"]; ?>">
                        <?php
                            if(strlen($this->newbook[$i]["name"])>20)
                            {
                                $pos=strpos($this->newbook[$i]["name"], " ", 20);
                                if($pos!=False)
                                {
                                    echo substr($this->newbook[$i]["name"], 0,$pos+1).'...';
                                }
                                else
                                    echo $this->newbook[$i]["name"];
                            }
                            else
                                echo $this->newbook[$i]["name"];
                        ?>
                    </a><br/>
                    Tác giả:
                    <a>
                    <?php
                        if(strlen($this->newbook[$i]["author"])>15)
                        {
                            $pos=strpos($this->newbook[$i]["author"], " ", 15);
                            if($pos!=False)
                            {
                                echo substr($this->newbook[$i]["author"], 0,$pos+1).'...';
                            }
                            else
                                echo $this->newbook[$i]["author"];
                        }
                        else
                            echo $this->newbook[$i]["author"];
                    ?>
                    </a><br/>
                    <?php
                        if(((int)$this->newbook[$i]["saleoff"])>0)
                        {
                            echo "<span class='oldprice'>Giá gốc:".$this->newbook[$i]["cost"]." đ</span><br/>";
                            echo "<span class='price'>Giá bán:".($this->newbook[$i]["cost"]*(100-$this->newbook[$i]["saleoff"])/100)." đ</span>";
                        }
                        else
                            echo "<span class='price'>Giá bán:".$this->newbook[$i]["cost"]." đ</span>";
                    ?>
                </td>
            <?php

                if($i== count($this->newbook)-1)
                {
                    echo "</tr>";
                }
            ?>
            <?php }?>
        </table>
